package com.sc.adminspringboot.utils;

import lombok.Data;

@Data
public class ResponseMsg {

    public static final int SUCCESS = 200;           // 请求成功处理并返回正确结果
    public static final int ERROR = -200;            // 通用错误，未明确指定错误类型
    public static final int ACCOUNT_ERROR = -201;    // 用户账号不存在或账号信息有误
    public static final int PARAM_ERROR = -202;      // 请求参数缺失、格式错误或参数值不合法
    public static final int AUTH_ERROR = -203;       // 用户权限不足，无法访问该资源或执行该操作
    public static final int NOT_FOUND = -204;        // 请求的资源未找到，如查询不存在的数据记录
    public static final int SERVER_ERROR = -205;     // 服务器内部发生未预期的异常或错误
    public static final int TIMEOUT_ERROR = -206;    // 请求处理超时或连接超时
    public static final int VALIDATION_ERROR = -207; // 数据验证失败，如字段格式、长度或业务规则校验不通过
    public static final int Status_ERROR = -208;     // 管理员状态异常被禁用了
    public static final int TOKEN_EXPIRED = -209;     // Token已过期，需要重新登录获取新的Token
    public static final int TOKEN_INVALID = -210;    // Token无效，可能是格式错误、被篡改或不存在


    private Integer code; //响应状态码
    /**
     * msg:添加成功/添加失败/未知错误
     */
    private String msg; //响应提示信息

    private Object data; //响应的具体数据，不同业务不同数据

    public ResponseMsg() {
    }

    private ResponseMsg(Integer code) {
        this.code = code;
    }

    private ResponseMsg(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private ResponseMsg(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private ResponseMsg(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public static ResponseMsg success() {
        return new ResponseMsg(200);
    }

    public static ResponseMsg success(Integer code) {
        return new ResponseMsg(code);
    }

    public static ResponseMsg getInstance(Integer code, String msg) {
        return new ResponseMsg(code, msg);
    }

    public static ResponseMsg getInstance(Integer code, String msg, Object data) {
        return new ResponseMsg(code, msg, data);
    }

    public static ResponseMsg getInstance(Integer code, Object data) {
        return new ResponseMsg(code, data);
    }


}
